{#
   This is the base template used as the application layout which contains the
   common elements and decorates all the other templates.
   See https://symfony.com/doc/current/templates.html#template-inheritance-and-layouts
#}
<!DOCTYPE html>
<html lang="{{ app.request.locale }}">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <meta name="view-transition" content="same-origin" />
        <title>{% block title %}Symfony Demo application{% endblock %}</title>
        <link rel="alternate" type="application/rss+xml" title="{{ 'rss.title'|trans }}" href="{{ path('blog_rss') }}">

        {#
            Those two blocks defines frontend entrypoint for CSS and JavaScript assets
            See https://symfony.com/doc/current/frontend.html
        #}
        {% block stylesheets %}{% endblock %}
        {% block javascripts %}
            {% block importmap %}{{ importmap('app') }}{% endblock %}
        {% endblock %}
        <link rel="shortcut icon" type="image/svg+xml" href="{{ asset('favicon.svg') }}">
    </head>

    <body id="{% block body_id %}{% endblock %}">

        {% block header %}
            {% set _route = app.request.get('_route') %}
            <header>
                <nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-primary">
                    <div class="container">
                        <a class="navbar-brand" href="{{ path('homepage') }}">
                            Symfony Demo
                        </a>
                        <button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#appNavbar" aria-controls="appNavbar" aria-expanded="false" aria-label="Toggle navigation">
                        <span class="navbar-toggler-icon"></span>
                        </button>

                        <div class="navbar-collapse collapse" id="appNavbar">
                            <ul class="navbar-nav ml-auto">
                                {% block header_navigation_links %}
                                    <li class="nav-item{{ _route == 'blog_index' ? ' active' : '' }}">
                                        <a class="nav-link" href="{{ path('blog_index') }}">
                                            <twig:ux:icon name="tabler:home"/> {{ 'menu.homepage'|trans }}
                                        </a>
                                    </li>
                                    {% if is_granted('ROLE_ADMIN') %}
                                        <li class="nav-item">
                                            <a class="nav-link" href="{{ path('admin_post_index') }}">
                                                <twig:ux:icon name="tabler:lock"/> {{ 'menu.admin'|trans }}
                                            </a>
                                        </li>
                                    {% endif %}
                                {% endblock %}

                                <li class="nav-item{{ _route == 'blog_search' ? ' active' : '' }}">
                                    <a class="nav-link" href="{{ path('blog_search') }}"> <twig:ux:icon name="tabler:search"/> {{ 'menu.search'|trans }}</a>
                                </li>

                                {% if app.user %}
                                    <li class="nav-item dropdown">
                                        <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" id="user">
                                            <twig:ux:icon name="tabler:user"/>
                                            <span class="caret"></span>
                                            <span class="sr-only">{{ app.user.fullname }}</span>
                                        </a>
                                        <div class="dropdown-menu user" role="menu" aria-labelledby="user">
                                            <a class="dropdown-item" href="{{ path('user_edit') }}">
                                                <twig:ux:icon name="tabler:id-badge-2"/> {{ 'menu.user'|trans }}
                                            </a>
                                            <div class="dropdown-divider"></div>
                                            <a class="dropdown-item" href="{{ logout_path() }}">
                                                <twig:ux:icon name="tabler:logout"/> {{ 'menu.logout'|trans }}
                                            </a>
                                        </div>
                                    </li>
                                {% endif %}

                                <li class="nav-item dropdown">
                                    {% from 'default/_language_selector.html.twig' import render_language_selector %}
                                    {{ render_language_selector() }}
                                </li>
                            </ul>
                        </div>
                    </div>
                </nav>
            </header>
        {% endblock %}

        <div class="container body-container">
            {% block body %}
                <div class="row">
                    <div id="main" class="col-sm-9">
                        {{ include('default/_flash_messages.html.twig') }}

                        {% block main %}{% endblock %}
                    </div>

                    <div id="sidebar" class="col-sm-3">
                        {% block sidebar %}
                            {{ render_esi(controller('Symfony\\Bundle\\FrameworkBundle\\Controller\\TemplateController::templateAction', {
                                'template': 'blog/about.html.twig',
                                'sharedAge': 600,
                                '_locale': app.request.locale
                            })) }}
                        {% endblock %}
                    </div>
                </div>
            {% endblock %}
        </div>

        {% block footer %}
            <footer>
                <div class="container">
                    <div class="row">
                        <div id="footer-copyright" class="col-md-6">
                            <p>&copy; {{ 'now'|date('Y') }} - The Symfony Project</p>
                            <p>{{ 'mit_license'|trans }}</p>
                        </div>
                        <div id="footer-resources" class="col-md-6">
                            <p>
                                <a rel="noopener noreferrer" target="_blank" href="https://twitter.com/symfony" title="Symfony on X (formerly Twitter)">
                                    <twig:ux:icon name="tabler:brand-x" font-size="28px" /> <span class="sr-only">X/Twitter</span>
                                </a>
                                <a target="_blank" href="https://symfony.com/blog/" title="Symfony Blog">
                                    <twig:ux:icon name="tabler:rss" font-size="28px" /> <span class="sr-only">RSS feed</span>
                                </a>
                            </p>
                        </div>
                    </div>
                </div>
            </footer>
        {% endblock %}

        {# it's not mandatory to set the timezone in localizeddate(). This is done to
           avoid errors when the 'intl' PHP extension is not available and the application
           is forced to use the limited "intl polyfill", which only supports UTC and GMT #}
        <!-- Page rendered on {{ 'now'|format_datetime('long', 'long', '', 'UTC') }} -->
    </body>
</html>
